package com.iwuke.dance.util;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.RadioButton;

import com.iwuke.dance.R;

/**
 * @author: 魏从响
 * @date: 2025/9/17
 */
public class RadioGroupUtil {

    private final Context context;
    private final RadioButton radio_button_1;
    private final RadioButton radio_button_2;
    private final View v_bottom_1;
    private final View v_bottom_2;

    public RadioGroupUtil(Context context, RadioButton radio_button_1, RadioButton radio_button_2, View v_bottom_1, View v_bottom_2) {

        this.context = context;
        this.radio_button_1 = radio_button_1;
        this.radio_button_2 = radio_button_2;
        this.v_bottom_1 = v_bottom_1;
        this.v_bottom_2 = v_bottom_2;
    }

    public void setRadioButtonColor(int rbn) {
        switch (rbn){
            case 1:
                radioButtonColorUtil(R.color.color_5ed,R.color.color_666);
                v_bottom_1.setVisibility(View.VISIBLE);
                v_bottom_2.setVisibility(View.INVISIBLE);
                break;

            case 2:
                radioButtonColorUtil(R.color.color_666,R.color.color_5ed);
                v_bottom_1.setVisibility(View.INVISIBLE);
                v_bottom_2.setVisibility(View.VISIBLE);
                break;

        }
    }

    private void radioButtonColorUtil(int color1,int color2){
        if (context==null||((Activity)context).isFinishing()){
            return;
        }
        radio_button_1.setTextColor(context.getResources().getColor(color1,null));
        radio_button_2.setTextColor(context.getResources().getColor(color2,null));
    }

}
